/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : menu.c /Project:AVOS		                **
**        Revision : 1.1                                       	**
**                                                             	**
*****************************************************************/
#include "menu.h"
#include "user.h"
#include "ctrlconvert.h"
INT8U CurrentOsdSize=0 ;

	extern PHWND (*fpCreateMenuWinMoviePlayBack)();
	extern PHWND (*fpCreateMenuWinFileList)();
	extern PHWND (*fpCreateMenuWinFileTypeSelect)();
	extern PHWND (*fpCreateMenuWinDeviceSelect)();
	extern PHWND (*fpCreateMenuLoadingWin)();
	extern PHWND (*fpCreateMenuWin15Pic)();
	extern PHWND (*fpCreateWinSetupMenu)();
	extern PHWND (*fpCreateMenuWinPicInfoBar)();
	extern PHWND (*fpCreateMenuWinLogo)();
	extern PHWND (*fpCreateMenuWinConfirm)();
	extern PHWND (*fpCreateMenuWinAviSub)();
	extern PHWND (*fpCreateMenuDivxSub)();
	extern PHWND (*fpCreateScreenSaver)();
	extern PHWND (*fpCreateMenuWinPeripheralDev)();
	extern PHWND (*fpCreateMenuWinDebug)();
	

void RegisterAllUseControl()
{
    AWRegisterTWindow();
    AWRegisterTControl();
    AWRegisterTMenu();
    AWRegisterTFilelist();
}

HWND * GUICreateWindow(char *pWindowName)
{
    HWND *pHwnd = AWFindWinCtrlByName(pWindowName) ;
	if(pHwnd)//this window already exist
		return NULL;
#ifdef ENABLE_NETWORK
	if(strcmp(pWindowName,"Win15Pic_net") == 0)
		pHwnd = CreateMenuWin15Pic_net();
	else
    	if(strcmp(pWindowName,"Network_Setup") == 0)
        	pHwnd = CreateMenuNetwork_Setup();
    	else
	if(strcmp(pWindowName,"WinKeyBoard") == 0)
        pHwnd = CreateMenuWinKeyBoard();
	else	
	if(strcmp(pWindowName,"WinNumberKeyBoard") == 0)
        pHwnd = CreateMenuWinNumberKeyBoard();
	else	
#endif	
	if(strcmp(pWindowName,WinMoviePlayBack) == 0)
        pHwnd = (*fpCreateMenuWinMoviePlayBack)();
    else		

    if(strcmp(pWindowName,WinFileList) == 0)
        pHwnd = (*fpCreateMenuWinFileList)();
    else
    if(strcmp(pWindowName,WinFileTypeSelect) == 0)
        pHwnd = (*fpCreateMenuWinFileTypeSelect)();
    else
    if(strcmp(pWindowName,WinDeviceSelect) == 0)
        pHwnd = (*fpCreateMenuWinDeviceSelect)();
    else
    if(strcmp(pWindowName,LoadingWin) == 0)
        pHwnd = (*fpCreateMenuLoadingWin)();
    else
    if(strcmp(pWindowName,Win15Pic) == 0)
        pHwnd = (*fpCreateMenuWin15Pic)();
    else
	if(strcmp(pWindowName,WinDebug) == 0)
        pHwnd = (*fpCreateMenuWinDebug)();
	else		
    if(strcmp(pWindowName,WinSetup_net_menu) == 0)
        pHwnd = (*fpCreateWinSetupMenu)();
    else
    if(strcmp(pWindowName,WinPicInfoBar) == 0)
        pHwnd = (*fpCreateMenuWinPicInfoBar)();
    else
    if(strcmp(pWindowName,WinLogo) == 0)
        pHwnd = (*fpCreateMenuWinLogo)();
    else
    if(strcmp(pWindowName,WinConfirm) == 0)
        pHwnd = (*fpCreateMenuWinConfirm)();	        
    else
    if(strcmp(pWindowName,WinAviSub) == 0)
        pHwnd = (*fpCreateMenuWinAviSub)();	
    else
	if(strcmp(pWindowName,WinDivxSub) == 0)
		pHwnd = (*fpCreateMenuDivxSub)();
    else
	if(strcmp(pWindowName,"ScrSaver") == 0)
        pHwnd = (*fpCreateScreenSaver)();
    else
	if(strcmp(pWindowName,WinPeripheralDev) == 0)
		pHwnd = (*fpCreateMenuWinPeripheralDev)();
    else
        ASSERT(1,"GUICreateWindow:Cannot create window...");
    return pHwnd;
}

void GUIDestoryWindow(char *pWindowName)
{
	HWND *pHwnd = AWFindWinCtrlByName(pWindowName) ;
	if(pHwnd){
		HWND *pCtrlRoot = AWGetRootWin() ;
		if(pCtrlRoot != pHwnd->parent){
			ASSERT(1,"GUIDestoryWindow: This control is not a window...");
			return ;
		}
		AWPostMessage(pCtrlRoot, WM_DESTROY_CONTROL, (INT32S)pHwnd) ;//destory it
	}
	return ;
}

void GUIShowWindow(char *pWindowName)
{
	HWND *pHwnd = AWFindWinCtrlByName(pWindowName) ;
	if(!pHwnd){
		GUICreateWindow(pWindowName) ;
		pHwnd = AWFindWinCtrlByName(pWindowName) ;
		if(pHwnd)
			AWShowWindow(pHwnd, 1) ;
	}
	else
		AWShowWindow(pHwnd, 1) ;
	return ;
}

void GUIHideWindow(char *pWindowName)
{
		AWHideWindowByName(pWindowName) ;
	return ;
}
